package com.example.expinterview.exception;

import com.example.expinterview.entity.enums.ErrorCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @classname: InterviewException
 * @description: TODO 业务错误类
 * @author: kaiser
 * @date: 2021/8/31 13:23
 * @version: 1.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class InterviewException extends RuntimeException {

    protected String errorCode;
    protected String errorMsg;

    public InterviewException() {
        super();
    }

    public InterviewException(ErrorCodeEnum code) {
        super(code.getCode());
        this.errorCode = code.getCode();
        this.errorMsg = code.getMsg();
    }

    public InterviewException(ErrorCodeEnum code, Throwable cause) {
        super(code.getCode(), cause);
        this.errorCode = code.getCode();
        this.errorMsg = code.getMsg();
    }

    public InterviewException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public InterviewException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }
}
